﻿@using DWEIP.Common;
@using DWEIP.Models.Sys;
@using DWEIP.Web.Core;
@using DWEIP.Locale;
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index_Layout.cshtml";

    List<permModel> perm = null;
}
<div class="mvctool">
    <select class="searchDrop" id="selCheck">
        <option value="1">全部</option>
        <option value="2">审核</option>
        <option value="3">未审核</option>
    </select>
    <input id="txtQuery" type="text" class="searchText" />
    @Html.ToolButton("btnQuery", "fa fa-search", Resource.Query, ref perm, "Query", true)
    @Html.ToolButton("btnCreate", "fa fa-plus", Resource.Create, ref perm, "Create", true)
    @Html.ToolButton("btnEdit", "fa fa-pencil", Resource.Edit, ref perm, "Edit", true)
    @Html.ToolButton("btnCheck", "fa  fa-check", Resource.Check, ref perm, "Check", true)
    @Html.ToolButton("btnUnCheck", "fa  fa-ban", Resource.UnCheck, ref perm, "UnCheck", true)
    @Html.ToolButton("btnDelete", "fa fa-trash", Resource.Delete, ref perm, "Delete", true)
</div>
<table id="List"></table>

<div id="modalwindow" class="easyui-window" data-options="modal:true,closed:true,minimizable:false,shadow:false"></div>
@Html.Partial("~/Views/Shared/_Partial_AutoGrid.cshtml")
<script type="text/javascript">
    $(function () {
        $('#List').datagrid({
            url: '@Url.Action("GetList")',
            width: SetGridWidthSub(10),
            methord: 'post',
            height: SetGridHeightSub(45),
            fitColumns: true,
            sortName: 'pk_id',
            sortOrder: 'asc',
            idField: 'pk_id',
            pageSize: 15,
            pageList: [15, 20, 30, 40, 50],
            pagination: true,
            striped: true, //奇偶行是否区分
            singleSelect: true,//单选模式
            //rownumbers: true,//行号
            columns: [[
                { field: 'pk_id', title: '@Resource.TitleID', width: 80, hidden: true },
                { field: 'folder_title', title: '频道', width: 80, sortable: true, hidden: true },
                { field: 'title', title: '主旨', width: 280, sortable: false },
                { field: 'publish_date', title: '發文日期', width: 80, sortable: true },
                { field: 'blt_type', title: '公佈類別', width: 80, sortable: true }
            ]]
        }).datagrid({
            rowStyler: function (index, row) {
               
            }
        });
    });
    //ifram 返回
    function frameReturnByClose() {
        $("#modalwindow").window('close');
    }
    function frameReturnByReload(flag) {
        if (flag)
            $("#List").datagrid('load');
        else
            $("#List").datagrid('reload');
    }
    function frameReturnByMes(mes) {
        $.messageBox5s('@Resource.Tip', mes);
    }
    $(function () {
        $("#btnCreate").click(function () {
            $("#modalwindow").html("<iframe width='100%' height='100%' scrolling='auto' frameborder='0'' src='/OA/Nbltm001/Create'></iframe>");
            $("#modalwindow").window({ title: '@Resource.Create', width: 700, height: 600, iconCls: 'fa fa-plus' }).window('open');
        });
        $("#btnEdit").click(function () {
            var row = $('#List').datagrid('getSelected');
            if (row != null) {
                $("#modalwindow").html("<iframe width='100%' height='100%' scrolling='auto' frameborder='0' src='/OA/Nbltm001/Edit?id=" + row.pk_id + "&Ieguid=" + GetGuid() + "'></iframe>");
                $("#modalwindow").window({ title: '@Resource.Edit', width: 700, height: 600, iconCls: 'fa fa-pencil' }).window('open');
            } else { $.messageBox5s('@Resource.Tip', '@Resource.PlaseChooseToOperatingRecords'); }
        });
        $("#btnQuery").click(function () {
            var queryStr = $("#txtQuery").val();
            if (queryStr == null) {
                queryStr = "%";
            }
            $("#List").datagrid("load", { queryStr: encodeURI(queryStr), checkFlag: $("#selCheck").val() });
        });
        $("#btnDelete").click(function () {
            var row = $('#List').datagrid('getSelected');
            if (row != null) {
                $.messager.confirm('@Resource.Tip', '@Resource.YouWantToDeleteTheSelectedRecords', function (r) {
                    if (r) {
                        $.post("@Url.Action("Delete")?id=" + row.pk_id, function (data) {
                            if (data.type == 1)
                                $("#List").datagrid('load');
                            $.messageBox5s('@Resource.Tip', data.message);
                        }, "json");

                    }
                });
            } else { $.messageBox5s('@Resource.Tip', '@Resource.PlaseChooseToOperatingRecords'); }
        });
        $("#btnCheck").click(function () {
            var row = $('#List').datagrid('getSelected');
            if (row != null) {
                $.ajax({
                    url: "/MIS/ManageArticle/Check",
                    type: "Post",
                    data: { Id: row.Id },
                    dataType: "json",
                    success: function (data) {
                        if (data.type == 1)
                            $("#List").datagrid('reload');
                        $.messageBox5s('@Resource.Tip', data.message);
                    }
                });
            } else { $.messageBox5s('@Resource.Tip', '@Resource.PlaseChooseToOperatingRecords'); }
        });
        $("#btnUnCheck").click(function () {
            var row = $('#List').datagrid('getSelected');
            if (row != null) {
                $.ajax({
                    url: "/MIS/ManageArticle/UnCheck",
                    type: "Post",
                    data: { Id: row.Id },
                    dataType: "json",
                    success: function (data) {
                        if (data.type == 1)
                            $("#List").datagrid('reload');
                        $.messageBox5s('@Resource.Tip', data.message);
                    }
                });
            } else { $.messageBox5s('@Resource.Tip', '@Resource.PlaseChooseToOperatingRecords'); }
        });

    });
</script>
